package com.ruoyi.project.platform.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.platform.domain.PltUserOrderDetail;
import com.ruoyi.project.platform.service.IPltUserOrderDetailService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 订单明细Controller
 * 
 * @author ruoyi
 * @date 2020-07-27
 */
@RestController
@RequestMapping("/platform/detail")
public class PltUserOrderDetailController extends BaseController
{
    @Autowired
    private IPltUserOrderDetailService pltUserOrderDetailService;

    /**
     * 查询订单明细列表
     */
    @PreAuthorize("@ss.hasPermi('platform:detail:list')")
    @GetMapping("/list")
    public TableDataInfo list(PltUserOrderDetail pltUserOrderDetail)
    {
        startPage();
        List<PltUserOrderDetail> list = pltUserOrderDetailService.selectPltUserOrderDetailList(pltUserOrderDetail);
        return getDataTable(list);
    }

    /**
     * 导出订单明细列表
     */
    @PreAuthorize("@ss.hasPermi('platform:detail:export')")
    @Log(title = "订单明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(PltUserOrderDetail pltUserOrderDetail)
    {
        List<PltUserOrderDetail> list = pltUserOrderDetailService.selectPltUserOrderDetailList(pltUserOrderDetail);
        ExcelUtil<PltUserOrderDetail> util = new ExcelUtil<PltUserOrderDetail>(PltUserOrderDetail.class);
        return util.exportExcel(list, "detail");
    }

    /**
     * 获取订单明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('platform:detail:query')")
    @GetMapping(value = "/{detailId}")
    public AjaxResult getInfo(@PathVariable("detailId") Long detailId)
    {
        return AjaxResult.success(pltUserOrderDetailService.selectPltUserOrderDetailById(detailId));
    }

    /**
     * 新增订单明细
     */
    @PreAuthorize("@ss.hasPermi('platform:detail:add')")
    @Log(title = "订单明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PltUserOrderDetail pltUserOrderDetail)
    {
        return toAjax(pltUserOrderDetailService.insertPltUserOrderDetail(pltUserOrderDetail));
    }

    /**
     * 修改订单明细
     */
    @PreAuthorize("@ss.hasPermi('platform:detail:edit')")
    @Log(title = "订单明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PltUserOrderDetail pltUserOrderDetail)
    {
        return toAjax(pltUserOrderDetailService.updatePltUserOrderDetail(pltUserOrderDetail));
    }

    /**
     * 删除订单明细
     */
    @PreAuthorize("@ss.hasPermi('platform:detail:remove')")
    @Log(title = "订单明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{detailIds}")
    public AjaxResult remove(@PathVariable Long[] detailIds)
    {
        return toAjax(pltUserOrderDetailService.deletePltUserOrderDetailByIds(detailIds));
    }
}
